package com.dubbo.consumer.regController;

import com.alibaba.dubbo.config.annotation.Reference;
import com.dubbo.common.dtos.ResponseResult;
import com.dubbo.model.balance.dtos.PageRequestDto;
import com.dubbo.model.regulate.dtos.AddrManagementDto;
import com.dubbo.model.regulate.pojos.RegManagement;
import com.dubbo.regulate.regulateService;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;
/*
* 服务分类
* */
@RestController
@RequestMapping("/regulate")
public class ManageController {

    @Reference(check = false)
    private regulateService regulateService;

    /**
     * 页面展示
     * @return
     */
    @GetMapping("/parentsRegulateList")
    public ResponseResult<List<RegManagement>> parentsRegulateList(PageRequestDto dto){

        return regulateService.parentsRegulateList(dto);
    }

    /*
    * 新增服务项目类
    * */
    @PostMapping("/add")
    public ResponseResult AddServiceClass(@RequestBody Map<String,Object> dto){
        Integer sManageId = (Integer) dto.get("sManageId");
        String sItem = (String) dto.get("sItem");

        AddrManagementDto managementDto = new AddrManagementDto();
        managementDto.setSManageId(sManageId);
        managementDto.setSItem(sItem);

        return regulateService.AddServiceClass(managementDto);
    }

    /*
    * 修改服务项目类
    * */
   @PostMapping("/Update")
    public ResponseResult UpdateServiceClass(@RequestBody Map<String,Object> up){
       Integer sManageId = (Integer) up.get("sManageId");
       String sItem = (String) up.get("sItem");

       AddrManagementDto managementDto = new AddrManagementDto();
       managementDto.setSManageId(sManageId);
       managementDto.setSItem(sItem);

       return regulateService.UpdateServiceClass(managementDto);
    }

    //测试
    @GetMapping("/test")
    private ResponseResult we(){
        return regulateService.test();
    }



}
